package com.iflytek.exam.mapper;

import java.util.List;
import com.iflytek.exam.domain.ExamGrade;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 试卷成绩Mapper接口
 * 
 * @author KK
 * @date 2024-07-08
 */
public interface ExamGradeMapper 
{
    /**
     * 查询试卷成绩
     * 
     * @param id 试卷成绩主键
     * @return 试卷成绩
     */
    public ExamGrade selectExamGradeById(Long id);

    /**
     * 查询试卷成绩列表
     * 
     * @param examGrade 试卷成绩
     * @return 试卷成绩集合
     */
    public List<ExamGrade> selectExamGradeList(ExamGrade examGrade);

    /**
     * 新增试卷成绩
     * 
     * @param examGrade 试卷成绩
     * @return 结果
     */
    public int insertExamGrade(ExamGrade examGrade);

    /**
     * 修改试卷成绩
     * 
     * @param examGrade 试卷成绩
     * @return 结果
     */
    public int updateExamGrade(ExamGrade examGrade);

    /**
     * 删除试卷成绩
     * 
     * @param id 试卷成绩主键
     * @return 结果
     */
    public int deleteExamGradeById(Long id);

    /**
     * 批量删除试卷成绩
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteExamGradeByIds(Long[] ids);

    ExamGrade selectExamGradeByExamId(Long examId);

    @Select("select id, user_id, exam_id, single_total_score, multiple_total_score, " +
            "judge_total_score, short_answer_total_score, total_score, is_pass, status, create_time, " +
            "time  from tb_exam_grade where exam_id = #{examId} and user_id = #{userId}")
    ExamGrade selectExamGradeByExamIdAndUserId(@Param("examId") Long examId, @Param("userId") Long userId);

    @Delete("delete from tb_exam_grade where exam_id = #{examId} and user_id = #{userId};")
    void deleteExamGradeByExamIdAndUserId(@Param("examId") Long examId, @Param("userId") Long userId);
}
